home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / dtime / data.1 / WIN32SUP.H < prev   
C/C++ Source or Header  |  1996-07-08  |  4KB  |  140 lines

  1. /*
  2. Module : WIN32SUP.H
  3. Purpose: Defines a number of components to allow dtime code to be portable across
  4.          Win32n(NT), Win32c(95), Win32s, Win16 & Dos
  5. Created: PJN / DATE/2 / 29-04-1996
  6. History: None
  7.  
  8. Copyright (c) 1996 by PJ Naughter.  
  9. All rights reserved.
  10.  
  11. */
  12.  
  13. #ifndef __WIN32SUP_H__
  14.  
  15.         
  16. ////////////////////////////////// Macros /////////////////////////////////////
  17.  
  18. #define __WIN32SUP_H__
  19.  
  20. #ifndef __cplusplus
  21.   #error Requires C++ compilation (use a .cpp suffix)
  22. #endif                 
  23.  
  24.  
  25. #ifdef _WIN32
  26.  
  27.   // Anything which is required from Win16 or Dos when compiling on Win32
  28.   #define EXPORT16
  29.  
  30. #else
  31.  
  32.   // Anything which is required when compiling on Win16 or Dos
  33.   
  34.   /////////////// defines /////////////////////////////////////////////////////
  35.   #define AFX_EXT_API
  36.   #define AFX_EXT_CLASS
  37.   
  38.   #define TIME_ZONE_ID_UNKNOWN  0
  39.   #define TIME_ZONE_ID_STANDARD 1
  40.   #define TIME_ZONE_ID_DAYLIGHT 2
  41.   
  42.   #ifdef _WINDOWS
  43.   #define _tprintf Win16Printf
  44.   #define EXPORT16 __export   
  45.   #define TCHAR char
  46.   #define LPCTSTR LPCSTR
  47.   #elif _DOS
  48.   #define _tprintf printf
  49.   #define TCHAR char
  50.   #define EXPORT16
  51.   #endif
  52.   #define _T(x) x
  53.  
  54.                                                     
  55.   /////////////// Structures //////////////////////////////////////////////////
  56.   typedef struct _SYSTEMTIME 
  57.   {
  58.     WORD wYear;
  59.     WORD wMonth;
  60.     WORD wDayOfWeek;
  61.     WORD wDay;
  62.     WORD wHour;
  63.     WORD wMinute;
  64.     WORD wSecond;
  65.     WORD wMilliseconds;
  66.   } SYSTEMTIME, *PSYSTEMTIME, FAR *LPSYSTEMTIME;
  67.                        
  68.   typedef struct _ULARGE_INTEGER 
  69.   {
  70.     DWORD LowPart; 
  71.     DWORD HighPart; 
  72.   } ULARGE_INTEGER, *PULARGE_INTEGER, FAR *LPULARGE_INTEGER; 
  73.                                   
  74.   typedef struct _TIME_ZONE_INFORMATION 
  75.   {
  76.     LONG Bias;
  77.     char StandardName[32];
  78.     SYSTEMTIME StandardDate;
  79.     LONG StandardBias;
  80.     char DaylightName[32];
  81.     SYSTEMTIME DaylightDate;
  82.     LONG DaylightBias;
  83.   } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, FAR *LPTIME_ZONE_INFORMATION;
  84.                                                 
  85.   
  86.   ////////////// Emulation of required Win32 functions ////////////////////////
  87.   DWORD EXPORT16 GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation);
  88.   
  89.   
  90.   ////////////// Functions which should have been in Win16 to begin with //////
  91.   #ifdef _WINDOWS
  92.   char* EXPORT16 DLLGetEnv(const char* pszVariableName);  //emulation of getenv for a Win16 DLL                    
  93.   #endif
  94.  
  95.  
  96.   //////////// A CString Class with Format support ////////////////////////////
  97.   class CStringEx : public CString
  98.   {
  99.   public:       
  100.     //Constructors / Destructors
  101.     EXPORT16 CStringEx();
  102.     EXPORT16 CStringEx(const CString& stringSrc);
  103.     EXPORT16 CStringEx(char ch, int nRepeat = 1);
  104.     EXPORT16 CStringEx(const char* psz);
  105.     EXPORT16 CStringEx(const char* pch, int nLength);
  106.                           
  107.     //Operations
  108.     void EXPORT16 Format(const char* pszFormat, ...);
  109.     void EXPORT16 Format(UINT nFormatID, ...);
  110.     
  111.     //As there is no console APIS on Win16 we will output the info via OutputDebugString                         
  112.     #ifdef _WINDOWS
  113.     friend int EXPORT16 Win16Printf(const char *format, ...);
  114.     #endif
  115.     
  116.     #ifndef _WINDOWS  //emulation of the LoadString function on Dos
  117.     BOOL LoadString(UINT nID);            
  118.     #endif
  119.   
  120.   protected:
  121.     void FormatV(const char* pszFormat, va_list argList);
  122.   };
  123.   
  124.   #define LOBYTE(w)     ((BYTE)(w))
  125.   #define HIBYTE(w)     ((BYTE)(((UINT)(w) >> 8) & 0xFF))
  126.  
  127.   #define CString CStringEx
  128.  
  129. #endif // _WIN32        
  130.  
  131.  
  132. //////////// function to wrap call to DllGetEnv when in a Win16 DLL ///////////
  133. char* EXPORT16 MyGetEnv(const char* pszVariableName); 
  134.  
  135.  
  136. #ifdef _DOS  //emulation of usual MFC function if on Dos
  137. void AfxFormatString1(CStringEx& rString, UINT nIDS, const char* psz1);
  138. #endif
  139.         
  140. #endif //__WIN32SUP_H__